package com.libgdxbar.pvzlikegame.systems.animation;

import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import org.libgdxbar.projects.interfaces.animation.GdxAnimation;

public class GdxAnimationImpl implements GdxAnimation {

    private String name;
    private boolean loop;
    private Animation<TextureRegion> animation;
    private float duration;

    public GdxAnimationImpl(String name, Animation<TextureRegion> animation) {
        this.name = name;
        this.animation = animation;
        this.duration = animation.getAnimationDuration();
    }

    public String getName() {
        return name;
    }

    public GdxAnimationImpl setName(String name) {
        this.name = name;
        return this;
    }

    public void loop(boolean loop) {
        this.loop = loop;
    }

	@Override
    public TextureRegion getFrame(float stateTime) {
        return animation.getKeyFrame(stateTime);
    }

    public float getDuration() {
        return this.duration;
    }
}
